package logicaPersistencia;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Properties;

public class MainServidor 
{


	public static void main(String[] args)
	{

		try {
			

			Fachada fac = Fachada.getInstancia();
			
			Properties p = new Properties();
			String nomArch = "config/Datos.properties";
			p.load(new FileInputStream (nomArch));
			
			String ip = p.getProperty("ipservidor");
			String puerto = p.getProperty("puerto");
			String nombre = p.getProperty("nombre");
			
			String ruta = "//" + ip + ":" + puerto + "/" + nombre;
			int port = Integer.parseInt(puerto);
		    
			Registry registry = LocateRegistry.createRegistry(port);
	        registry.rebind(nombre, fac); 
			
			System.out.println("Fachada publicada en: " + ruta);
		
		
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}



	}

}
